<template>
  <div class="mask" :style="{height: height + 'px'}" @click="maskClick" v-if="showDialog">
    <div class="dialog" >
      <div class="dialog-body" >
        <slot></slot>
      </div>
      <div class="dialog-footer">
        <div class="btn" @click="cancel"><div style="margin-top: 3px;">取消</div></div>
        <div class="btn" @click="dialogConfirm"><div style="margin-top: 3px;">确定</div></div>
      </div>
    </div>
  </div>
</template>
<script>
  export default {
    name: 'BaseDialog',
    props: {
      showDialog: {
        type: Boolean,
        default() {
          return false
        }
      },
      dialogHeight: {
        type: [Number,String],
        default() {
          return 75
        }
      },
      footerText: {
        type: String,
        default() {
          return '我知道了'
        }
      }
    },
    computed: {
      top(){
        return (window.innerHeight - this.dialogHeight) / 2
      }
    },
    data() {
      return {
        height: window.innerHeight,
        // left: window.innerWidth * 0.2 / 2
      }
    },
    methods:{
      maskClick(){
        this.$emit('maskClick')
      },
      cancel(){
        this.$emit('cancel')
      },
      dialogConfirm(){
        this.$emit('dialogConfirm')
      }
    }
  }
</script>
<style scoped>
  .mask{
    position: fixed;
    left: 0;
    top: 0;
    width: 100%;
    background-color: rgba(0,0,0,0.5);
    z-index: 1000;
    /* background-image: url(../assets/backgroundImg.png);
    background-repeat: no-repeat;
    background-size: 100% 100%; */
    
    
  }
  .dialog{
    position: absolute;
    top: 6.25rem;
    width: 9rem;
    background-color: #f3f3f3;
    z-index: 1001;
    border-radius: 10px;
    left: 0.89rem;
    height: 4.95rem;
  }
  .dialog-body{
    font-size: 0.5rem;
    padding: 0.75rem 0.7rem 0.6rem 0.7rem;
    text-align: center;
    line-height: 0.95rem;
  }
  .dialog-footer{
    
    padding: 10px 15px;
    display: flex;
    justify-content: space-around;
  }
  .dialog-footer .btn{
    width: 3.6rem;
    height: 1rem;
    border: 1px solid #444;
    text-align: center;
    border-radius:20px; 
    color:black
  }
</style>
